package org.example.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.pojo.Vendor;

import java.util.List;

@Mapper
public interface VendorMapper {
    /**
     * 查询所有供应商
     * @return
     */
    @Select("select * from vendor")
    List<Vendor> list();

    /**
     * 分页查询供应商
     * @param vendorName
     * @return
     */
    Page<Vendor> listPage(String vendorName);

    /**
     * 添加供应商
     * @param vendor
     */
    @Insert("insert into vendor(vendor_name,description,create_time,update_time,phone) " +
            "values(#{vendorName},#{description},#{createTime},#{updateTime},#{phone})")
    void add(Vendor vendor);

    /**
     * 修改供应商
     * @param vendor
     */
    void update(Vendor vendor);

    /**
     * 删除供应商
     * @param id
     */
    @Delete("delete from vendor where id = #{id}")
    void delete(Integer id);
}
